{% extends "sentry/bases/account.html" %}

{% load crispy_forms_tags %}
{% load i18n %}
{% load sentry_avatars %}
{% load sentry_helpers %}
{% load sentry_features %}

{% block wrapperclass %}narrow account-settings{% endblock %}

{% block title %}{% trans "Account Settings" %} | {{ block.super }}{% endblock %}

{% block main %}
    {% if not email.is_verified %}
      <div class="alert alert-warning alert-block">
        {% trans "Your email address has not been verified. " %}
        <form action="{% url 'sentry-account-confirm-email-send' %}" method="post" class="email-alert-button">
          {% csrf_token %}
          <input type="hidden" name="email" value="{{ email.email }}">
          <button type="submit" name="primary-email" class="btn-link">{% trans "Resend Verification Email." %}</button>
        </form>
      </div>
    {% endif %}

    <form action="" method="post">
        {% csrf_token %}
        {{ form|as_crispy_errors }}

        <legend style="margin-top: 0;">Your details</legend>

        <div class="account-settings-overview">
          <div class="avatar-preview">
            <label class="control-label">Avatar</label>
            <div>
              <a class="avatar-edit-link" href="{% url 'sentry-account-settings-avatar' %}">
                <span class="avatar">
                {% avatar request.user 118 %}
                </span>
                <span class="icon-settings"></span>
              </a>
            </div>
          </div>
          <div class="account-settings-body">
            {% with form.name as field %}
              {{ field|as_crispy_field }}
            {% endwith %}
            {% if form.username %}
              {% with form.username as field %}
                {{ field|as_crispy_field }}
              {% endwith %}
            {% endif %}
            {% with form.email as field %}
              {{ field|as_crispy_field }}
            {% endwith %}
            {% if form.new_password %}
              <p class="help-block pull-right" style="margin-top: 0">({% trans "Optional" %})</p>
              {% with form.new_password as field %}
                {{ field|as_crispy_field }}
              {% endwith %}
              {% with form.verify_new_password as field %}
                {{ field|as_crispy_field }}
              {% endwith %}
            {% endif %}
          </div>
        </div>

        {% if form.password %}
          <legend>{% trans "Verification"  %}</legend>
          {% with form.password as field %}
              {{ field|as_crispy_field }}
          {% endwith %}
        {% endif %}

        {% if not form.is_readonly %}
          <fieldset class="form-actions">
              <button type="submit" class="btn btn-primary">{% trans "Save Changes" %}</button>
          </fieldset>
        {% endif %}
    </form>
{% endblock %}
